home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / tcoop.arc / TCOOP2.ARC / EXPENSE1.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-10-26  |  1.4 KB  |  47 lines

  1. /* expense1.c: A structured version of the trip expense program */
  2.  
  3. #include <stdio.h>
  4. #include <string.h>
  5.  
  6. struct ExpenseRec { /* The trip expense record */
  7.   char TripName[80], Date[80];
  8.   int Mileage, Cost, Fringe;
  9. };
  10.  
  11. void CheckWithBoss(struct ExpenseRec ExRec)
  12. /* The boss is very tough. He won't approve every trip. */
  13. {
  14.   if (!stricmp(ExRec.TripName, "Hawaii") ||
  15.     !stricmp(ExRec.TripName, "Tahiti"))
  16.     printf("%s: You are fired for trying to sneak this one by\n",
  17.         ExRec.TripName);
  18.   else if (ExRec.Cost/4 < ExRec.Fringe)
  19.     printf("The fringe expenses for the %s trip are too high\n",
  20.         ExRec.TripName);
  21.   else printf("The %s trip is ok\n", ExRec.TripName);
  22. }
  23.  
  24. int I, ExCount;
  25. struct ExpenseRec ExRec[20];  /* A list of employee records */
  26.  
  27. main()
  28. {
  29.   printf("How many trips did you take? ");
  30.   scanf("%d", &ExCount);
  31.   for (I=0; I<ExCount; I++) {
  32.     printf("Please enter the name of your trip: ");
  33.     scanf("%s", ExRec[I].TripName);
  34.     printf("Which date did you leave (mo/day/year)? ");
  35.     scanf("%s", ExRec[I].Date);
  36.           printf("Enter the number of miles for your trip: ");
  37.     scanf("%d", &ExRec[I].Mileage);
  38.           printf("Enter the cost of your trip: ");
  39.        scanf("%d", &ExRec[I].Cost);
  40.           printf("Enter the cost of your meals and entertainment: ");
  41.     scanf("%d", &ExRec[I].Fringe);
  42.   }
  43.   for (I=0; I<ExCount; I++) CheckWithBoss(ExRec[I]);
  44.   return 0;
  45. }
  46.  
  47.